/*
 * BookDetails.fx
 * Author：Yu Min-ting
 * Created on 2009-7-20, 14:22:14
 */

package com.sjtu.fx.book;

import com.sjtu.fx.tools.Panel;
import javafx.scene.*;

import javafx.scene.layout.*;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;

import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.control.Label;

import javafx.scene.shape.Line;

import javax.swing.JTextArea;
import javafx.scene.control.Hyperlink;

import com.sjtu.fx.comments.*;

import com.sjtu.fx.tools.SwingTextArea;

public class BookDetails extends CustomNode {
    var panel:Panel;
    public var waitingList:WaitingList;
    public var comments:BookDetailsComments;
    var writeComment:WriteComments;
    var similarBooks:SimilarBooks;
    public var bookname:String = "Network Analysis, Architecture, and Design, Third Edition";
    public var author:String ="James McCabe";
    public var description:String ="xxxxxxxx test test test test test\nxxxxxxx\nxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxx";
    public var coverURL:String ;
    public var isbn:String = "0-08-054875-X";
    public var publisher:String ="Morgan Kaufmann";
    public var bookScore:String = "5";
    public var labels:String= "Network Analysis Architecture Design";
    public var avgScore:Double on replace with{
        writeComment.aScore = avgScore;
        };
    public var waitingNumber:Integer;
    public var bookNumber:String;
    public var bookId:Integer;
    public var userId:Integer;
   
    var nameLabel = Label {
            text: bind bookname
            font: Font {size:10 name: "Verdana Bold"}
            textFill: Color.rgb(11,51,60)
    };

    var isbnText = Text {
        font: Font {size:10 name: "Verdana"}
        fill: Color.rgb(11,51,60)
        content: "Book ISBN:"
    };
     var isbnLabel = Label {
            text: bind isbn
            font: Font {size:10 name: "Verdana Bold"}
            textFill: Color.rgb(11,51,60)
    };
    var authorText = Text {
        font: Font {size:10 name: "Verdana"}
        fill: Color.rgb(11,51,60)
        content: "Book Author: "
    };
     var authorLabel = Label {
            text: bind author
            font: Font {size:10 name: "Verdana Bold"}
            textFill: Color.rgb(11,51,60)
    };
    var publisherText = Text {
        font: Font {size:10 name: "Verdana"}
        fill: Color.rgb(11,51,60)
        content: "Book Publisher: "
    };
     var publisherLabel = Label {
            text: bind publisher
            font: Font {size:10 name: "Verdana Bold"}
            textFill: Color.rgb(11,51,60)
    };
    var keywordText = Text {
        font: Font {size:10 name: "Verdana"}
        fill: Color.rgb(11,51,60)
        content: "Book Keyword: "
    };
     var keywordLabel = Label {
            text: bind labels
            font: Font {size:10 name: "Verdana Bold"}
            textFill: Color.rgb(11,51,60)
    };
    var scoreText = Text {
        font: Font {size:10 name: "Verdana"}
        fill: Color.rgb(11,51,60)
        content: "Check in Score: "
    };
     var scoreLabel = Label {
            text: bind bookScore
            font: Font {size:10 name: "Verdana Bold"}
            textFill: Color.rgb(11,51,60)
    };
     var numberText = Text {
        font: Font {size:10 name: "Verdana"}
        fill: Color.rgb(11,51,60)
        content: "Book Quantity : "
    };
    var descriptionText = Text {
        font: Font {size:14 name: "Verdana Bold"}
        fill: Color.DARKGRAY
        content: "Overview : "
    };
   
   var scrollPane = SwingTextArea {
            columns:65
            rows:2
            editable:false
            text: bind description
   }

   var waiting = Hyperlink {
           text: "Waiting List >>"
           action: function() {
                waitingList.visible = true;
                comments.visible = false;
                writeComment.visible = false;
                similarBooks.visible = false;
           }
       }
   var comment = Hyperlink {
           text: "Book Comments >>"
           action: function() {
                comments.visible = true;
                waitingList.visible = false;
                writeComment.visible = false;
                similarBooks.visible = false;
           }
       }

   var rate = Hyperlink {
           text: "Rate This Book >>"
           action: function() {
                writeComment.visible = true;
                comments.visible = false;
                waitingList.visible = false;
                similarBooks.visible = false;

           }
       }
   var similar = Hyperlink {
           text: "More Similar Books >>"
           action: function() {
               similarBooks.visible = true;
               writeComment.visible = false;
               comments.visible = false;
               waitingList.visible = false;

           }
       }

    public var image = Image{
        url: "{__DIR__}{coverURL}.jpg" 
        };
     
    override protected function create() : Node {
      
        Group{
            content:[
                 panel = Panel {
                    width:    780
                    height:   550
                    title:    "BookDetails"
                    translateX: 0
                    translateY: 0
                },
                HBox{
                    spacing: 10
                    translateX:20 translateY: 50
                    content:[
                        ImageView{
                        image:bind image
                        },
                        VBox{
                            spacing: 3                  
                            content:[
                                HBox{
                                    spacing:3
                                    content:[nameLabel]
                                },
                                HBox{
                                    spacing:3
                                    content:[isbnText,isbnLabel]
                                }
                                HBox{
                                    spacing:3
                                    content:[authorText,authorLabel]
                                },
                                HBox{
                                    spacing:3
                                    content:[publisherText,publisherLabel]
                                },
                                HBox{
                                    spacing:3
                                    content:[keywordText,keywordLabel]
                                },
                                HBox{
                                    spacing:3
                                    content:[scoreText,scoreLabel]
                                }

                           ]
                       },
                      VBox{
                            spacing: 10
                            translateX:100
                            content:[waiting,comment,rate,similar]
                      }
                    ]
                },
                 Line {
                    startX: 15
                    startY: 155
                    endX: 765
                    endY: 155
                    stroke:Color.rgb(196,227,227)
                },
                VBox{
                    spacing:6
                    translateX:20 translateY:165
                    content:[descriptionText,scrollPane]
                },
                waitingList = WaitingList{translateY:245}
                comments = BookDetailsComments{translateY:245 visible:false}
                writeComment = WriteComments{translateY:245 visible:false}
                similarBooks = SimilarBooks{translateY:245 visible:false}
            ]
        }
     }

}
